﻿/* ######################################## *\
 * ### Copyright (C) 2009 AJ Ravindiran ### *
 * ### HTTP://THEAJ.NET/ <AJ@THEAJ.NET> ### *
\* ######################################## */
using System;

namespace AJRavindiran.Jolt.RuneScape.Characters.Information
{
    /// <summary>
    /// Represents the details stored in the database for the player's character.
    /// </summary>
    public class Details
    {
        #region Fields
        /// <summary>
        /// The player's connection ID. This is a temperary key given to all 
        /// players on login. It will be recycled after the player goes offline.
        /// This ID will never change during gameplay. Only if the user relogs.
        /// </summary>
        private int mConnectionID = 0;

        /// <summary>
        /// The player's database ID. This is a static ID and will NEVER change.
        /// The ID is grabbed from the database table field "id".
        /// </summary>
        private int mDatabaseID = 0;

        /// <summary>
        /// The player's username. This is a static string thoughout gameplay.
        /// If anyhow the name is changed from the database, the player needs
        /// to relog, or use the refresh username function.
        /// </summary>
        private string mUsername;

        /// <summary>
        /// The player's password. This is a static string thoughout gameplay.
        /// The password must be changed via a PHP form. The password is
        /// encrypted with SHA and self-user salt for security.
        /// </summary>
        private string mPassword;

        /// <summary>
        /// The player's rights. This is a static int thoughout gameplay.
        /// The rights determine what commands and what features this 
        /// character can access within gameplay.
        /// </summary>
        private byte mRights = 0;

        /// <summary>
        /// The player's connection status. Determines if the player 
        /// is online, or offline. Changes when the player logs in, or
        /// logs off.
        /// </summary>
        private bool mOnline = false;
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the Connection ID. The set function can only be 
        /// used at player login when assinging the connection ID.
        /// </summary>
        public int ConnectionID
        {
            get { return mConnectionID; }
            set { mConnectionID = value; }
        }

        /// <summary>
        /// Gets or sets the Database ID. The set function can only be
        /// used at player login when assinging the id from the database.
        /// </summary>
        public int DatabaseID
        {
            get { return mDatabaseID; }
            set { mDatabaseID = value; }
        }

        /// <summary>
        /// Gets or sets the player's character username.
        /// </summary>
        public string Username
        {
            get { return mUsername; }
            set { mUsername = value; }
        }

        /// <summary>
        /// Gets or sets the player's character password.
        /// </summary>
        public string Password
        {
            get { return mPassword; }
            set { mPassword = value; }
        }

        /// <summary>
        /// Gets or sets the player's character rights.
        /// </summary>
        public byte Rights
        {
            get { return mRights; }
            set { mRights = value; }
        }

        /// <summary>
        /// Gets or sets the player's connection status.
        /// </summary>
        public bool Online
        {
            get { return mOnline; }
            set { mOnline = value; }
        }
        #endregion

        #region Methods
        /// <summary>
        /// Set all the details for the player.
        /// </summary>
        /// <param name="connectionID">The connection ID of the palyer's character.</param>
        /// <param name="databaseID">The database ID of the player's character.</param>
        /// <param name="username">The username of the player's character.</param>
        /// <param name="password">The password of the player's character.</param>
        /// <param name="rights">The rights of the player's characters</param>
        /// <param name="online">Is the player online or not.</param>
        public void SetDetails(int connectionID, int databaseID, string username, string password, byte rights, bool online)
        {
            connectionID = mConnectionID;
            databaseID = mDatabaseID;
            username = mUsername;
            password = mPassword;
            rights = mRights;
            online = mOnline;
        }
        #endregion
    }
}
